﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using KCMS.DataAcsess.Interfaces;
using KCMS.DataAcsess.Entitys;

namespace KCMS.DataAcsess.Engine
{
    public class SettingsManager : ISettingsManager
    {
        private XDocument xml = XDocument.Load(AppDomain.CurrentDomain.BaseDirectory + "KCMSSettings.xml");
        public Entitys.SettingsEntity getSettings()
        {
           SettingsEntity settings = new SettingsEntity();

            settings.SmtpServer = xml.Root.Element("SmtpServer").Value;
            settings.SmtpPort = int.Parse(xml.Root.Element("SmtpPort").Value);
            settings.SmtpLogin = xml.Root.Element("SmtpLogin").Value;
            settings.SmtpPassword = xml.Root.Element("SmtpPassword").Value;
            settings.FeedBackReceiver = xml.Root.Element("Receiver").Value;
            settings.SaleStepFirst =double.Parse(xml.Root.Element("SaleStepFirst").Value);
            settings.SaleStepSecond = double.Parse(xml.Root.Element("SaleStepSecond").Value);
            settings.SaleStepThird = double.Parse(xml.Root.Element("SaleStepThird").Value);
            settings.UploadDirectory = xml.Root.Element("UploadDirectory").Value;
            settings.SaleStepFirstPercent =double.Parse(xml.Root.Element("SaleStepFirstPercent").Value);
            settings.SaleStepSecondPercent = double.Parse(xml.Root.Element("SaleStepSecondPercent").Value);
            settings.SaleStepThirdPercent = double.Parse(xml.Root.Element("SaleStepThirdPercent").Value);
            settings.SaleMinimum = double.Parse(xml.Root.Element("SaleMinimum").Value);
            return settings;
        }
    }
}
